function DivResizer(div,resizer)
{
	this.resizer = resizer;
	this.div=div;
	this.box=document.getElementById('ebagridresizebox_');
	if(this.box==null)
	{
		this.box=document.createElement('div');
		this.box.id='ebagridresizebox_';
		document.body.appendChild(this.box);
		this.box.className='ntbcolumnresizeline';
	}
}

DivResizer.prototype.startResize=function(evt){
	//debugger;
	var _2cb=null;
	var x,y;
	var _2ce=nitobi.html.getEventCoords(evt);
	x=evt.offsetX;//_2ce.x;
	y=evt.offsetY;//_2ce.y;
	this.x=_2ce.x;//x;
	this.y=_2ce.y;
	var w=this.div.style.pixelWidth;
	var h=this.div.style.pixelHeight;
	var L=0;//this.div.offsetLeft;
	var T=0;//this.div.offsetTop;
	this.resizeW=true;//(Math.abs((x-L)-w)<3)||((Math.abs((y-T)-h)<16)&&(Math.abs((x-L)-w)<16));
	this.resizeH=true;//(Math.abs((y-T)-h)<3)||((Math.abs((y-T)-h)<16)&&(Math.abs((x-L)-w)<16));
	if(this.resizeW||this.resizeH){
		this.box.style.cursor=(this.resizeW&&this.resizeH)?'NW-Resize':(this.resizeW)?'W-Resize':'N-Resize';
		this.box.style.visibility='visible';
		this.box.style.width=(x-L)+'px';
		this.box.style.height=(y-T)+'px';
		var _2d3=nitobi.drawing.align.SAMEWIDTH|nitobi.drawing.align.SAMEHEIGHT|nitobi.drawing.align.ALIGNTOP|nitobi.drawing.align.ALIGNLEFT;
		nitobi.drawing.align(this.box,this.div,_2d3,0,0,0,0,false);
		this.dd=new nitobi.ui.DragDrop(this.box,false,false);
		this.dd.onDragStop.subscribe(this.endResize,this);
		this.dd.onMouseMove.subscribe(this.resize,this);
		this.dd.startDrag(evt);
	}
};

DivResizer.prototype.resize=function(){
	//debugger;
	var x=this.dd.x;
	var y=this.dd.y;
	var L=this.div.offsetLeft;
	var T=this.div.offsetTop;
	this.box.style.visibility='visible';
	if(this.resizeW){
		this.div.innerHtml = 'x = ' + x + ' : this.x = ' + this.x + ' : box.pixelWidth = ' + this.box.style.pixelWidth;
		this.box.style.width= this.div.style.pixelWidth + (x-this.x)+'px';
	}
	if(this.resizeH)
		this.box.style.height=this.div.style.pixelHeight + (y-this.y)+'px';
};

DivResizer.prototype.endResize=function(){
	var x=this.dd.x;
	var y=this.dd.y;
	this.box.style.visibility='hidden';
	var _2da=this.div.style.pixelWidth;
	var _2db=this.div.style.pixelHeight;
	var _2dc=parseInt(_2da)+((this.resizeW)?x-this.x:0);
	var _2dd=parseInt(_2db)+((this.resizeH)?y-this.y:0);
	
	if(isNaN(_2dc)||isNaN(_2dd))
		return;
	
	if(_2dc>20&&_2dd>20){
		this.div.style.width = _2dc + 'px';
		this.div.style.height = _2dd + 'px';
		var base = document.getElementById(this.resizer + '_toolbarArea').parentElement;
		var tbHeight = base.children[0].offsetHeight;
		var tabHeight = base.children[4].offsetHeight
		this.resizer.style.height = (_2dd - tbHeight - tabHeight - 20) + 'px'; //this.resizer.offsetHeight + (y - this.y) + 'px';
	}
};

DivResizer.prototype.dispose=function(){this.grid=null;};
function start(){sr.startResize(window.event);}
